home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 19 / Amiga Plus Leser CD 19.iso / Tools / Freeware / Swf_Player / Lib / swf.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-17  |  6.2 KB  |  253 lines

  1. #ifndef _SWF_H_
  2. #define _SWF_H_
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <setjmp.h>
  8. #include <assert.h>
  9. #include <limits.h>
  10.  
  11. #ifdef DUMP
  12. #include "bitstream.h"
  13. #endif
  14.  
  15. #include "flash.h"
  16.  
  17. extern int debug;
  18.  
  19. //#define DEBUG
  20.  
  21. #ifdef DEBUG
  22. #define TRACE(fmt,args...) printf(fmt,args...)
  23. #else
  24. #define TRACE(fmt,args...)
  25. #endif
  26.  
  27. // Global Types
  28. typedef unsigned long U32, *P_U32, **PP_U32;
  29. typedef signed long S32, *P_S32, **PP_S32;
  30. typedef unsigned short U16, *P_U16, **PP_U16;
  31. typedef signed short S16, *P_S16, **PP_S16;
  32. typedef unsigned char U8, *P_U8, **PP_U8;
  33. typedef signed char S8, *P_S8, **PP_S8;
  34. typedef signed long SFIXED, *P_SFIXED;
  35. typedef signed long SCOORD, *P_SCOORD;
  36. #ifndef AMIGA
  37. typedef unsigned long BOOL;
  38. #else
  39. #include <exec/types.h>
  40. #endif
  41.  
  42. #define ZOOM(v,f) ((v)/(f))
  43.  
  44. #include "matrix.h"
  45. #include "cxform.h"
  46. #include "rect.h"
  47.  
  48. #ifndef AMIGA
  49. #include <sys/time.h>
  50. #else
  51.     #ifdef __PPC__
  52.         #include <sys/time.h>
  53.     #else
  54.         #include <devices/timer.h>
  55.     #endif // __PPC__
  56. #endif
  57. #define ST struct timeval t1,t2;
  58. #define START gettimeofday(&t1,0)
  59. #define STOP(msg) gettimeofday(&t2,0); printf("%s Delta = %d ms\n", msg, (t2.tv_sec-t1.tv_sec)*1000+(t2.tv_usec-t1.tv_usec)/1000); fflush(stdout);
  60.  
  61.  
  62. // Start Sound Flags
  63. enum {
  64.     soundHasInPoint        = 0x01,
  65.     soundHasOutPoint    = 0x02,
  66.     soundHasLoops        = 0x04,
  67.     soundHasEnvelope    = 0x08
  68.  
  69.     // the upper 4 bits are reserved for synchronization flags
  70. };
  71.  
  72. // Flags for Sound Format
  73. enum SounfFlags {
  74.     soundIsStereo        = 0x01,
  75.     soundIs16bit        = 0x02,
  76.     soundIsADPCMCompressed    = 0x10
  77. };
  78.  
  79. // Flags for defining Button States
  80. enum ButtonState {
  81.     stateHitTest = 0x08,
  82.     stateDown    = 0x04,
  83.     stateOver    = 0x02,
  84.     stateUp      = 0x01
  85. };
  86.  
  87. // Actions
  88. enum Action {
  89.         // Internal actions
  90.         ActionRefresh        = 0x00,
  91.         ActionPlaySound        = 0x01,
  92.         // Normal actions
  93.         ActionGotoFrame        = 0x81,
  94.         ActionGetURL        = 0x83,
  95.         ActionNextFrame        = 0x04,
  96.         ActionPrevFrame        = 0x05,
  97.         ActionPlay        = 0x06,
  98.         ActionStop        = 0x07,
  99.         ActionToggleQuality    = 0x08,
  100.         ActionStopSounds    = 0x09,
  101.         ActionWaitForFrame    = 0x8a,
  102.         ActionSetTarget        = 0x8b,
  103.         ActionGoToLabel        = 0x8c
  104. };
  105.  
  106. class Sound;
  107.  
  108. struct ActionRecord {
  109.     Action             action;
  110.  
  111.     // GotoFrame  & WaitForFrame
  112.     long             frameIndex;
  113.  
  114.     // GetURL
  115.     char            *url;
  116.     char            *target;
  117.  
  118.     // GotoLabel
  119.     char            *frameLabel;
  120.  
  121.     // WaitForFrame
  122.     long             skipCount;
  123.  
  124.     // Sound
  125.     Sound            *sound;
  126.  
  127.     struct ActionRecord    *next;
  128.     
  129.     ActionRecord() {
  130.         frameLabel = 0;
  131.         url = 0;
  132.         target = 0;
  133.         sound = 0;
  134.     };
  135.  
  136.     ~ActionRecord() {
  137.         if (frameLabel) free(frameLabel);
  138.         if (url) free(url);
  139.         if (target) free(target);
  140.     };
  141. };
  142.  
  143. enum FontFlags {
  144.     fontUnicode   = 0x20,
  145.     fontShiftJIS  = 0x10,
  146.     fontANSI      = 0x08,
  147.     fontItalic    = 0x04,
  148.     fontBold      = 0x02,
  149.     fontWideCodes = 0x01
  150. };
  151.  
  152. enum TextFlags {
  153.     isTextControl = 0x80,
  154.  
  155.     textIsLarge   = 0x70,
  156.     textHasFont   = 0x08,
  157.     textHasColor  = 0x04,
  158.     textHasYOffset= 0x02,
  159.     textHasXOffset= 0x01
  160. };
  161.  
  162. #ifndef NULL
  163. #define NULL 0
  164. #endif
  165.  
  166. // Tag values that represent actions or data in a Flash script.
  167. enum
  168.     stagEnd             = 0,
  169.     stagShowFrame         = 1,
  170.     stagDefineShape        = 2,
  171.     stagFreeCharacter         = 3,
  172.     stagPlaceObject         = 4,
  173.     stagRemoveObject         = 5,
  174.     stagDefineBits         = 6,
  175.     stagDefineButton         = 7,
  176.     stagJPEGTables         = 8,
  177.     stagSetBackgroundColor    = 9,
  178.     stagDefineFont        = 10,
  179.     stagDefineText        = 11,
  180.     stagDoAction        = 12,
  181.     stagDefineFontInfo        = 13,
  182.     stagDefineSound        = 14,    // Event sound tags.
  183.     stagStartSound        = 15,
  184.     stagStopSound        = 16,
  185.     stagDefineButtonSound    = 17,
  186.     stagSoundStreamHead        = 18,
  187.     stagSoundStreamBlock    = 19,
  188.     stagDefineBitsLossless    = 20,    // A bitmap using lossless zlib compression.
  189.     stagDefineBitsJPEG2        = 21,    // A bitmap using an internal JPEG compression table.
  190.     stagDefineShape2        = 22,
  191.     stagDefineButtonCxform    = 23,
  192.     stagProtect            = 24,    // This file should not be importable for editing.
  193.  
  194.     // These are the new tags for Flash 3.
  195.     stagPlaceObject2        = 26,    // The new style place w/ alpha color transform and name.
  196.     stagRemoveObject2        = 28,    // A more compact remove object that omits the character tag (just depth).
  197.     stagDefineShape3        = 32,    // A shape V3 includes alpha values.
  198.     stagDefineText2        = 33,    // A text V2 includes alpha values.
  199.     stagDefineButton2        = 34,    // A button V2 includes color transform, alpha and multiple actions
  200.     stagDefineBitsJPEG3        = 35,    // A JPEG bitmap with alpha info.
  201.     stagDefineBitsLossless2     = 36,    // A lossless bitmap with alpha info.
  202.     stagDefineSprite        = 39,    // Define a sequence of tags that describe the behavior of a sprite.
  203.     stagNameCharacter        = 40,    // Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds).
  204.     stagFrameLabel            = 43,    // A string label for the current frame.
  205.     stagSoundStreamHead2    = 45,    // For lossless streaming sound, should not have needed this...
  206.     stagDefineMorphShape    = 46,    // A morph shape definition
  207.     stagDefineFont2        = 48,
  208.  
  209.     notEnoughData        = 0xffff,    // Special code
  210. };
  211.  
  212. #ifndef false
  213. #define false 0
  214. #endif
  215. #ifndef true
  216. #define true 1
  217. #endif
  218.  
  219. extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb;
  220.  
  221. typedef void (*ScanLineFunc)(void *id, long y, long start, long end);
  222.  
  223. class Bitmap;
  224. struct FlashMovie;
  225.  
  226.  
  227. extern "C" {
  228. #undef GLOBAL
  229. #include "jpeglib.h"
  230. };
  231. extern "C" {
  232. #undef GLOBAL
  233. #include "zlib.h"
  234. };
  235.  
  236. #include "graphic.h"
  237. #include "character.h"
  238. #include "bitmap.h"
  239. #include "shape.h"
  240. #include "displaylist.h"
  241. #include "sound.h"
  242. #include "button.h"
  243. #include "font.h"
  244. #include "text.h"
  245. #include "adpcm.h"
  246. #include "program.h"
  247. #include "sprite.h"
  248. #include "script.h"
  249. #include "movie.h"
  250.  
  251. #endif /* _SWF_H_ */
  252.